#ifndef __UIMANAGER_H__
#define __UIMANAGER_H__

#include <list>
#include <string>
#include <SFML/Graphics.hpp>
#include <Metgine/UI/Widget.h>

namespace Metgine
{
namespace UI
{

class METGINE_API UIManager
{
public:

    // Constructor
    UIManager();

    // Destructor
    ~UIManager();

    // Adds a widget to the UI
    void AddWidget(Widget* widget);

    // Removes a widget from the UI
    void RemoveWidget(Widget* widget);

    // Removes all widgets in the specified group
    void RemoveWidgetsInGroup(int group = Group::All);

    // Removes all widgets from the UI
    void RemoveAllWidgets();

    // Updates the UI
    void Update(float elapsedTime);

    // Renders the UI
    void Render();

    // Gets a widget by name
    Widget* GetWidget(const std::string& name);

    // Gets a widget by index
    Widget* GetWidget(int index);

    // Processes a key press. Returns false if the event wasn't handled.
    bool KeyDown(sf::Key::Code key, bool shift, bool control, bool alt);

    // Processes a key release. Returns false if the event wasn't handled.
    bool KeyUp(sf::Key::Code key, bool shift, bool control, bool alt);

    // Sets the exclusive input hook
    void SetInputHook(Widget* widget);

    Widget* operator [] (const std::string& name);
    Widget* operator [] (int index);
protected:
private:
        std::list<Widget*>             m_widgets;
        Widget*                        m_inputHook;

        bool Exists(Widget*);
};

}; // UI
}; // Metgine

#endif // UIMANAGER_H
